*******************************************************************************************************************************************MANUSCRIPT: Authorized Generic Entry prior to Patent Expiry: Reassessing Incentives for Independent Generic Entry *AUTHOR:     Silvia Appelt, University of Munich, silvia.appelt@lrz.uni-muenchen.de******************************************************************************************************************************************	   ***  Sets of potential generic entrants & therapeutic and drug form experience of potential and actual generic entrants ***						            		* Date last edit:  11 January 2015 * ******************************************************************************************************************************************   version 13.0set more offcap log closeclear** (I) Sets of potential generic entrants** 75 Drug Markets (no systemic use, lung or eye)use npi_human4.dta, clearsum sub_no_gentry_exp, dlocal num1=r(max)+1local x=1quietly while `x'<`num1' {  use npi_human4.dta, clear   keep sub_no sub_id sub_no_gentry_expby sub_no, sort: generate sub_intIndex=_nsum sub_intIndexdrop if  sub_intIndex!=1 drop if sub_no_gentry_exp!=`x'save sub`x', replace  local x=`x'+1}*A) First Group of Potential Entrants [active generic drug manufacturers]use npi_human4.dta, clearsum sub_no_gentry_exp, dlocal num1=r(max)+1local x=1quietly while `x'<`num1' {use npi_human4.dta, clear gen all_active= .sum date_expiry if sub_no_gentry_exp==`x'local expiry=r(min)     egen active`x'=tag(producer_no) if act_generics_no!= . & date_form_launch<`expiry'sum active`x'local act_`x'=r(max)if `act_`x''==0 {keep in 1replace hst_id= .replace producer_no= .}else if `act_`x''==1 {drop if active`x'!=1}replace all_active=`act_`x''drop active`x'duplicates drop producer_no, forcekeep producer_no hst_id producer act_generics_no all_activesort producer_nosave sub`x'_entrants, replace   local x=`x'+1}use npi_human4.dta, clearsum sub_no_gentry_exp, dlocal num=r(max)+1local x=1quietly while `x'<`num' {use sub`x', clear  cross using sub`x'_entrantssave npi_human_generic_entry1_`x', replace  local x=`x'+1}local x=1while `x'<`num' {erase sub`x'_entrants.dtalocal x=`x'+1}use npi_human_generic_entry1_1, clearlocal x=2quietly while `x'<`num' {append using npi_human_generic_entry1_`x'sort sub_no_gentry_exp producer_nolocal x=`x'+1}drop sub_intIndex sort sub_no_gentry_exp producer_nosave npi_human_generic_entry1, replace  local x=1quietly while `x'<`num' {erase npi_human_generic_entry1_`x'.dtalocal x=`x'+1}egen help=tag(sub_no_gentry_exp producer_no)count if help==1by sub_no_gentry_exp producer_no, sort: gen index=_ntab indexdrop index help**7491 obstab sub_no_gentry_exp if all_active==0*B) Second Group of Potential Entrants [active generic drug manufacturers with ATC3 & NFC1 experience]use npi_human4.dta, clear sum sub_no_gentry_exp, dlocal num1=r(max)+1local x=1quietly while `x'<`num1' {use npi_human4.dta, clear    gen all_active= .sum date_expiry if sub_no_gentry_exp==`x'local expiry=r(min)   egen index`x'=group(atc3_no nfc1_no) if sub_no_gentry_exp==`x'sum index`x'local num2=r(max)+1local y=1 quietly while `y'<`num2' {sum atc3_no if index`x'==`y'local match1=r(mean)sum nfc1_no if index`x'==`y'local match2=r(mean)egen help_tag`y'=tag(producer_no) if atc3_no==`match1' & nfc1_no==`match2' & act_generics_no!= . & date_form_launch<`expiry'local y=`y'+1}egen active`x'=rowmax(help_tag*)sum active`x'local act_`x'=r(max)if `act_`x''==0 {keep in 1replace hst_id= .replace producer_no= .}else if `act_`x''==1 {drop if active`x'!=1}replace all_active=`act_`x''drop index`x' help* active`x'duplicates drop producer_no, forcekeep producer_no hst_id producer act_generics_no all_activesort producer_nosort producer_nosave sub`x'_atc3nfc1_entrants, replace   local x=`x'+1}use npi_human4.dta, clear sum sub_no_gentry_exp, dlocal num=r(max)+1local x=1quietly while `x'<`num' {use sub`x', clear  cross using sub`x'_atc3nfc1_entrantssave npi_human_generic_entry2_`x', replace  local x=`x'+1}local x=1while `x'<`num' {erase  sub`x'.dtaerase sub`x'_atc3nfc1_entrants.dtalocal x=`x'+1}use npi_human_generic_entry2_1, clearlocal x=2quietly while `x'<`num'{append using npi_human_generic_entry2_`x'sort sub_no_gentry_exp producer_nolocal x=`x'+1}drop sub_intIndex sort sub_no_gentry_exp producer_nosave npi_human_generic_entry2, replace  local x=1quietly while `x'<`num' {erase npi_human_generic_entry2_`x'.dtalocal x=`x'+1}egen help=tag(sub_no_gentry_exp producer_no)count if help==1by sub_no_gentry_exp producer_no, sort: gen index=_ntab indexdrop index help**1836 obs (3 missings)tab sub_no_gentry_exp if all_active==0*22, 24, 75** (II) Therapeutic and drug form experience potential and actual generic entrants*Group of Potential Entrants + Generic Entrants (if not listed among potential entrants)*(1) Identify potential and actual generic entrants (group of potential entrants=active generic drug manufacturers)*(2) Match sets of potential and actual generic entrants to drug market *(3) Keep all drugs to measure experience of potential entrants*Active Generic Firms & Generic Entrantsuse npi_human4.dta, clearsum act_generics_no gentrant_no keep sub_id sub_no sub_no_gentry_exp producer_no act_generics_no* atc*_no atc*_id nfc*_no nfc*_id date_form_launch product product_no pzn_id_mod date_expiry gentrant_no generic_entry_exp drug_code firm_re_indexegen help_check=group(producer_no) if act_generics_no!= . | gentrant_no!= .sum help_checksort sub_no_gentry_exp producer_noegen help1=tag(sub_no_gentry_exp producer_no) if help_check!= .count if help1==1tab firm_re_index if help1==1*764 market entries (no reimport)egen help1b=tag(sub_no_gentry_exp gentrant_no) count if help1b==1*750 actual generic entries by sub_no_gentry_exp, sort: egen check=total(help1) if sub_no_gentry_exp!= .by sub_no_gentry_exp, sort: egen checkb=total(help1b) if sub_no_gentry_exp!= .  sum check*, ddrop check* help*sort sub_id producer_nosave npi_human3_template, replace*Merge with first of Potential Entrants (includes second, smaller group of potential entrants)use npi_human_generic_entry1.dta, clearsort sub_no_gentry_exp producer_noegen help1=tag(sub_no_gentry_exp producer_no) if producer_no!= . & sub_no_gentry_exp!= .count if help1==1*7491 potential generic entriesby sub_no_gentry_exp, sort: egen check=total(help1) if sub_no_gentry_exp!= .sum check, ddrop check help*sort sub_id producer_nomerge sub_id producer_no using npi_human3_template.dtatab _mtab _m if sub_no_gentry_exp!= .sum act_generics_no gentrant_no egen entrant_no=group(producer_no) if act_generics_no!= . | gentrant_no!= .sum entrant_noby producer_no, sort: egen entrant_no2=min(entrant_no) if producer_no!= .sum entrant_no2sort sub_no_gentry_exp producer_noegen help0=tag(sub_no_gentry_exp producer_no) if entrant_no!= . & sub_no_gentry_exp!= .count if help0==1*7543 potential generic entriesegen help1=tag(sub_no_gentry_exp producer_no) if entrant_no2!= . & sub_no_gentry_exp!= .count if help1==1*7559 potential market entries (not only generic entries)egen help1b=tag(sub_no_gentry_exp producer_no) if gentrant_no!= . & sub_no_gentry_exp!= .count if help1b==1*750 actual generic entriesby sub_no_gentry_exp, sort: egen check0=total(help0) if sub_no_gentry_exp!= .by sub_no_gentry_exp, sort: egen check=total(help1) if sub_no_gentry_exp!= .by sub_no_gentry_exp, sort: egen checkb=total(help1b) if sub_no_gentry_exp!= .sum check*, ddrop check help* _msum act_generics_no gentrant_no entrant_nokeep sub_id sub_no sub_no_gentry_exp producer_no act_generics_no* atc*_no atc*_id nfc*_no nfc*_id date_form_launch product product_no pzn_id_mod date_expiry gentrant_no generic_entry_exp drug_code entrant_no*save npi_human3_firm_effects.dta, replace**(i) Therapeutic experience (ATC3)use npi_human3_firm_effects.dta, cleargenerate atc3_exp2= .sort sub_no_gentry_expsum sub_no_gentry_exp, dlocal num=r(max)+1local x=1quietly while `x'<`num' {sum date_expiry if sub_no_gentry_exp==`x'local expiry=r(min)sum sub_id if sub_no_gentry_exp==`x'local sub_match=r(min)sort atc3_noegen index`x'=group(atc3_no) if sub_no_gentry_exp==`x'sum index`x', dlocal num2=r(max)+1local y=1quietly while `y'<`num2' {sum atc3_no if index`x'==`y'local atc_match=r(mean)egen help1_tag_`x'_`y'=tag(entrant_no2 product_no) if atc3_no==`atc_match' & date_form_launch<=`expiry' & sub_id!=`sub_match' & entrant_no2!= . & product_no!= .by entrant_no2 product, sort: egen help2_tag_`x'_`y'=max(help1_tag_`x'_`y') if entrant_no2!= . & product_no!= .drop help1*_tag*local y=`y'+1}egen help1`x'=rowmax(help2_tag_`x'_*)egen help2`x'=tag(entrant_no2 product_no) if entrant_no2!= . & product_no!= . & help1`x'==1by entrant_no2, sort: egen help3`x'=total(help2`x') if entrant_no2!= .by entrant_no2, sort: replace atc3_exp2=help3`x' if entrant_no2!= . & atc3_exp2== . & sub_no_gentry_exp==`x'drop index* help*local x=`x'+1}sum atc3_exp2, dsum sub_no_gentry_exp atc3_exp2*7543 observations (=potential generic entries)keep sub_no_gentry_exp producer_no entrant_no atc3_exp2sort sub_no_gentry_exp producer_nosave npi_atc3_exp_merge, replace**(ii) Drug form experience (NFC3)use npi_human3_firm_effects.dta, cleargenerate nfc3_exp2= .sort sub_no_gentry_expsum sub_no_gentry_exp, dlocal num=r(max)+1local x=1quietly while `x'<`num' {sum date_expiry if sub_no_gentry_exp==`x'local expiry=r(min)sum sub_id if sub_no_gentry_exp==`x'local sub_mnfch=r(min)sort nfc3_noegen index`x'=group(nfc3_no) if sub_no_gentry_exp==`x'sum index`x', dlocal num2=r(max)+1local y=1quietly while `y'<`num2' {sum nfc3_no if index`x'==`y'local nfc_mnfch=r(mean)egen help1_tag_`x'_`y'=tag(entrant_no2 product_no) if nfc3_no==`nfc_mnfch' & date_form_launch<=`expiry' & sub_id!=`sub_mnfch' & entrant_no2!= . & product_no!= .by entrant_no2 product, sort: egen help2_tag_`x'_`y'=max(help1_tag_`x'_`y') if entrant_no2!= . & product_no!= .drop help1*_tag*local y=`y'+1}egen help1`x'=rowmax(help2_tag_`x'_*)egen help2`x'=tag(entrant_no2 product_no) if entrant_no2!= . & product_no!= . & help1`x'==1by entrant_no2, sort: egen help3`x'=total(help2`x') if entrant_no2!= .by entrant_no2, sort: replace nfc3_exp2=help3`x' if entrant_no2!= . & nfc3_exp2== . & sub_no_gentry_exp==`x'drop index* help*local x=`x'+1}sum nfc3_exp2, dsum sub_no_gentry_exp nfc3_exp2*7543 observations (=potential generic entries)keep sub_no_gentry_exp producer_no entrant_no nfc3_exp2sort sub_no_gentry_exp producer_nosave npi_nfc3_exp_merge.dta, replace*** end of do file